package com.stu.entity.service;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.stu.entity.base.BaseEntity;
import com.stu.entity.permission.PermissionUser;


@Entity
@Table(name = "QUESTION")
public class Question extends BaseEntity{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private String title;
	private String content;
	private int readnum;
	private int ansnum;
	
	private PermissionUser user;
	private List<Answer> answers=new ArrayList<Answer>();
	
	@Column(name = "title", length = 200)
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	@Column(name = "content", length = 1000)
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	@Column(name = "readnum")
	public int getReadnum() {
		return readnum;
	}
	public void setReadnum(int readnum) {
		this.readnum = readnum;
	}
	@Column(name = "ansnum")
	public int getAnsnum() {
		return ansnum;
	}
	public void setAnsnum(int ansnum) {
		this.ansnum = ansnum;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "user")
	public PermissionUser getUser() {
		return user;
	}
	public void setUser(PermissionUser user) {
		this.user = user;
	}
	
	@OneToMany(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
	@JoinColumn(name = "QUESTION")
	public List<Answer> getAnswers() {
		return answers;
	}
	public void setAnswers(List<Answer> answers) {
		this.answers = answers;
	}
	public Question() {
		super();
	}
	@Override
	public String toString() {
		return "Question [title=" + title + ", content=" + content + ", readnum=" + readnum + ", ansnum=" + ansnum
				+ ", user=" + user + ", answers=" + answers + "]";
	}
	public Question(String uuid) {
		super(uuid);
	}
	
	
	
}
